import {
  BarChartOutlined,
  SettingOutlined,
  CopyOutlined,
  PicLeftOutlined,
  FileSearchOutlined,
  ExperimentOutlined,
  ContainerOutlined,
  ApartmentOutlined,
  AccountBookOutlined
} from '@ant-design/icons';
import type { MenuProps } from 'antd';
import { Link } from 'react-router-dom';
import React from 'react';
import { ItemType } from 'antd/lib/menu/hooks/useItems';

type MenuItem = Required<MenuProps>['items'][number];

function getItem(
  label: React.ReactNode,
  key: React.Key,
  icon?: React.ReactNode,
  children?: MenuItem[],
  type?: 'group',
): MenuItem {
  return {
    key,
    icon,
    children,
    label,
    type,
  } as MenuItem;
}

const reactHOC = (icon: string) => {
  return
}

let list: ItemType[] = []
const power = sessionStorage.getItem('power')
window.onload= () => {
  if (typeof power === 'string') {
    let _power = JSON.parse(power)
    list = _power.map((v:any) => {
      return getItem(v.permissionsTitle,'' + v.permissionsId,React.createElement(v.icon),[
        ...v.children.map((i:any) => getItem(<Link to={i.permissionsUrl}>{i.permissionsTitle}</Link>,i.permissionsId))
      ])
    })
  }
}




const list1: MenuProps['items'] = [
  getItem('首页', 'sub1', <BarChartOutlined />, [
    getItem(<Link to="/home/first/homepage">总览</Link>, '1'),
    getItem(<Link to="/todayBillboard">今日检验进度看板</Link>, '2'),
    getItem(<Link to="/qualityBillboard">IQC质量管理看板</Link>, '3'),
  ]),
  getItem('物料派单', 'sub2', <SettingOutlined />, [
    getItem(<Link to="/home/materialSingle">零星物料派单</Link>, '4'),
    getItem(<Link to="/home/Wms">WMS待派单</Link>, '5'),
  ]),
  getItem('物料检验', 'sub3', <SettingOutlined />, [
    getItem(<Link to="/home/materialMaterial">我的检验</Link>, '6'),
  ]),
  getItem('检验结果', 'sub4', <FileSearchOutlined />, [
    getItem(<Link to="/home/fourthly/inspectionResult">IQC主管审核</Link>, '7'),
    getItem(<Link to="/home/fourthly/supervisorAudit">质量主管审核</Link>, '8'),
  ]),
  getItem('综合查询', 'sub5', <SettingOutlined />, [
    getItem(<Link to="/home/comprehensiveInquiry">综合查询</Link>, '9'),
  ]),
  getItem('定点信息', 'sub6', <SettingOutlined />, [
    getItem(<Link to="/home/dotMessage">供应商清单</Link>, '10'),
    getItem(<Link to="/home/dotMaterial">定点物料</Link>, '11'),
  ]),
  getItem('基础管理', 'sub7', <SettingOutlined />, [
    getItem(<Link to="/home/basicManagement">物料组</Link>, '12'),
    getItem(<Link to="/home/materialManagement">物料管理</Link>, '13'),
    getItem(<Link to="/home/ProjectStandard">项目标准</Link>, '14'),
    getItem(<Link to="/home/inspectionItem">检验项目</Link>, '15'),
    getItem(<Link to="/home/samplingPlan">抽样方案</Link>, '16'),
    getItem(<Link to="/home/dataDictionary">数据字典</Link>, '17'),
  ]),
  getItem('资产管理', 'sub8', <SettingOutlined />, [
    getItem(<Link to="/home/assetsManagement">设备管理</Link>, '18'),
  ]),
  getItem('分析报表', 'sub9', <SettingOutlined />, [
    getItem(<Link to="/home/analyticalStatement">物料分析组</Link>, '19'),
    getItem(<Link to="/home/vendorAnalysis">供应商分析</Link>, '20'),
    getItem(<Link to="/home/yieldAnalysis">合格率分析</Link>, '21'),
  ]),
  getItem('绩效管理', 'sub10', <SettingOutlined />, [
    getItem(<Link to="/home/performanceManagement">检验员及时性</Link>, '22'),
  ]),
  getItem('权限管理', 'sub11', <SettingOutlined />, [
    getItem(<Link to="/home/authorityManagement">角色管理</Link>, '23'),
    getItem(<Link to="/home/userControl">用户管理</Link>, '24'),
    getItem(<Link to="/home/mailManagement">邮件组管理</Link>, '25'),
    getItem(<Link to="/home/autoSingle">自动派单设置</Link>, '26'),
  ]),
  getItem('帮助中心', 'sub12', <SettingOutlined />, [
    getItem(<Link to="/home/helpCenter">意见反馈</Link>, '27'),
  ]),
];



const title = {
  '/home/first': '首页',
  '/home/first/homepage': '总览',

  '/home/second': '物料派单',
  '/home/second/materialSingle': '零星物料派单',
  '/home/second/Wms': 'WMS待派单',

  '/home/thirdly': '物料检验',
  '/home/thirdly/materialMaterial': '我的检验',

  '/home/fourthly': '检验结果',
  "/home/fourthly/inspectionResult": 'IQC主管审核',
  "/home/fourthly/maintain1": '维护',
  '/home/fourthly/supervisorAudit': '质量主管审核',

  '/home/fifth': '综合查询',
  '/home/fifth/comprehensiveInquiry': '综合查询',
  "/home/fifth/redact": '综合查询',
  '/home/fifth/details': '综合查询',

  '/home/sixth': '定点信息',
  "/home/sixth/dotMessage": "供应商清单",
  "/home/sixth/dotMaterial": '定点物料',

  '/home/seventh': '基础管理',
  "/home/seventh/basicManagement": "物料组",
  "/home/seventh/materialManagement": "物料管理",
  "/home/seventh/ProjectStandard": "项目标准",
  "/home/seventh/inspectionItem": "检验项目",
  "/home/seventh/samplingPlan": "抽样方案",
  "/home/seventh/dataDictionary": "数据字典",

  '/home/eighth': '资产管理',
  "/home/eighth/assetsManagement": "设备管理",

  '/home/ninth': '分析报表',
  "/home/ninth/analyticalStatement": "物料分析组",
  "/home/ninth/vendorAnalysis": "供应商分析",
  "/home/ninth/yieldAnalysis": "合格率分析",

  '/home/tenth': '绩效管理',
  "/home/tenth/performanceManagement": "检验员及时性",

  '/home/eleventh': '权限管理',
  "/home/eleventh/authorityManagement": "角色管理",
  "/home/eleventh/userControl": "用户管理",
  "/home/eleventh/mailManagement": "邮件组管理",
  "/home/eleventh/autoSingle": "自动派单设置",

  '/home/twelfth': '帮助中心',
  "/home/twelfth/helpCenter": "意见反馈"
}

export { title }
export default list